package com.example.service.impl;

import com.example.mapper.DataMapper;
import com.example.pojo.Dept;
import com.example.service.DataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

@Service
public class DataServiceImpl implements DataService {
    @Autowired
    private DataMapper dataMapper;

    //查询全部部门方法
    @Override
    public List<Dept> findAll() {
        return dataMapper.findAll();
    }

    //删除部门方法
    @Override
    public void delete(Integer id){
        dataMapper.delete(id);
    }
    //添加部门方法
    public void add(Dept dept) {
       dept.setCreateTime(LocalDateTime.now());
       dept.setUpdateTime(LocalDateTime.now());
       dataMapper.add(dept);
    }
    //查询部门方法
    @Override
    public Dept select(Integer id) {
        return dataMapper.select(id);
    }
    //修改部门方法
    @Override
    public void update(Dept dept){
        dept.setUpdateTime(LocalDateTime.now());
        dataMapper.update(dept);
    }
}
